from PIL import Image
import pytesseract


im = Image.open("3.png")
imgry = im.convert('L')
#imgry.show()

threshold = 200
table = []

for i in range(256):
    if i < threshold:
        table.append(0)
    else:
        table.append(1)
out = imgry.point(table, '1')
#out.show()

vcode=pytesseract.image_to_string(out,lang='eng')
#code = vcode.replace(" ", "")
print('识别的验证码：'+vcode)